package com.inforeach.util.string;

import java.util.List;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import static java.util.Arrays.asList;

public class SmartUniquer_utest
{
    private SmartUniquer sut_;

    @Before
    public void setUp()
    {
        sut_ = new SmartUniquer(new StringSequenceGenerator(StringSequences.LATIN26_LOWER_STR));
    }

    @Test
    public void testAllUnique()
    {
        check(asList("Z", "Y", "X"), asList("Z", "Y", "X"));
    }

    @Test
    public void testGenAll()
    {
        check(asList("a", "b", "c"), asList("", "", ""));
    }

    @Test
    public void testGenSome()
    {
        check(asList("c", "a", "b"), asList("", "a", "b"));
    }

    @Test
    public void testGenForDuplicates()
    {
        check(asList("b", "a", "aa"), asList("", "a", "a"));
    }

    void check(List<String> expected, List<String> input)
    {
        List<String> result = sut_.process(input);
        Assert.assertSame(result, input);
        Assert.assertEquals(expected, input);
    }
}
